﻿using Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BLL;
using System.Web.Security;

namespace WebApplication2
{
    public partial class login : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
          
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            var username = tb_id.Text;
            var pwd = tb_password.Text;
            stutable model =stutableBLL.GetUser(username, pwd);
            if (model != null)
            {

                FormsAuthentication.RedirectFromLoginPage(username, true);
                if (model.role == 1)
                {
                    Response.Redirect("teacherinfo.aspx");
                }
                else
                {
                    Response.Redirect("WebForm1.aspx");
                }
            }
            else
            {
                Response.Write("<script>alert('账号或密码错误!')</script>");
            }
        }


    }
}